from django.db import models
#from django.core.files.storage import FileSystemStorage
# Create your models here.


class Login(models.Model):
    User = models.CharField(max_length=50)

    def __unicode__(self):
        return self.User


class Question(models.Model):

    question_type = models.CharField(default="Physics", max_length=20)
    question = models.TextField("Question given", max_length=1000)
    image = models.ImageField(upload_to="photos")
    pub_time = models.DateTimeField()

    all_select_num = models.IntegerField(default=0)
    right_select_num = models.IntegerField(default=0)

    def __unicode__(self):
        return self.question


class Answer(models.Model):
    IF_T = (
        ('T', 'right'),
        ('N', 'wrong'),
    )
    result = models.CharField(max_length=10, choices=IF_T)
    answer = models.TextField(max_length=1000)
    number = models.CharField(max_length=1)
    question = models.ForeignKey(Question)
    count = models.IntegerField(default=0)

    def if_right(self):
        return self.result

    def __unicode__(self):
        return self.answer

# answers 	= 	models.ForeignKey(Answer)
